'use strict';

const Controller = require('egg').Controller;

class LoginController extends Controller {
  async login() {
    let user = this.ctx.request.body.user;
    if(user.username === "admin" && user.password == "123"){
        let token = this.app.jwt.sign(user,this.app.config.jwt.secret)
        this.ctx.body = {
            code:200,
            msg:"验证成功",
            token:token
        }
    }else{
        this.ctx.body = {
            code:400,
            msg:"验证失败"
        }
    }
  }
  async getMessage(){
      let token = this.ctx.request.header.token;
  }
}

module.exports = LoginController;
